import {
	WFStepTraceViewActionType,
	IWFStepTraceViewAbility,
	IWFStepTraceViewControllerParams,
	IWFStepTraceViewModel,
	IWFStepTraceViewStore,
	IParam,
	IViewEvent,
} from '@/core';
import { QXEvent } from 'qx-util';
import {
	getViewClassNames,
	useViewAction,
	useViewBasic,
	useViewControllerParams,
	useViewProps,
} from '../use-view';

/**
 * 获取应用流程跟踪视图输入参数
 *
 * @export
 * @return {*}
 */
export function useWFStepTraceViewProps() {
	return {
		...useViewProps(),
		appDeCodeName: String,
	};
}

/**
 * 获取应用流程跟踪视图基础
 *
 * @export
 * @param {IWFStepTraceViewModel} model 应用流程跟踪视图模型
 * @param {IParam} props 输入参数
 * @return {*}
 */
export function useWFStepTraceViewBasic(
	model: IWFStepTraceViewModel,
	props: IParam
) {
	const getClassNames = (props: IParam) => {
		return getViewClassNames(model, props);
	};
	return {
		...useViewBasic(model, props),
		getClassNames,
	};
}

/**
 * 应用流程跟踪视图行为
 *
 * @export
 */
export function useWFStepTraceViewAction(controller: any) {
	return {
		...useViewAction(controller),
	};
}

/**
 * 获取应用流程跟踪视图控制器输入参数
 *
 * @export
 * @param {IWFStepTraceViewModel} model
 * @param {IParam} props
 * @param {QXEvent<IViewEvent<WFStepTraceViewActionType, IWFStepTraceViewAbility>>} evt
 * @return {*}  {IWFStepTraceViewControllerParams<WFStepTraceViewActionType, IWFStepTraceViewAbility>}
 */
export function useWFStepTraceViewControllerParams(
	model: IWFStepTraceViewModel,
	props: IParam,
	evt: QXEvent<IViewEvent<WFStepTraceViewActionType, IWFStepTraceViewAbility>>
): IWFStepTraceViewControllerParams<
	WFStepTraceViewActionType,
	IWFStepTraceViewAbility
> {
	return {
		...useViewControllerParams<IWFStepTraceViewStore, IWFStepTraceViewModel>(
			model,
			props,
			evt
		),
	};
}
